# -*- coding: UTF-8 -*-
from django.shortcuts import render_to_response
from easycity.busipanel.forms import SignupForm
from django.contrib.auth import REDIRECT_FIELD_NAME
from django.http import HttpResponseRedirect
from django.contrib.auth.decorators import login_required
from easycity.utils.CommonUtils import get_base_context_map

def signup(request, next_page=None):
    context_map=get_base_context_map(request)
    #context_map = {}
    #context_map['user'] = request.user
    form = SignupForm()
    if request.method == 'POST':
        form = SignupForm(request.POST)
        if form.is_valid():
            user_obj = form.save()
            from django.contrib import auth
            auth.login(request, user_obj)
            return HttpResponseRedirect(next_page or '/')
    context_map['form']=form
    return render_to_response('busipanel/signup.html',context_map)


